﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using vensoft.Entities;
using vensoft.BussinesLogic;

namespace vensoft.Win32
{
    public partial class frmMostrarHistoricoIngresoPedido : Form
    {
        IHistoricoIngresoPedidoBL historicopedidoBL;

        public frmMostrarHistoricoIngresoPedido()
        {
            InitializeComponent();
            historicopedidoBL = new HistoricoIngresoPedidoBL();
        }

        private void btnCancelar_Click(object sender, EventArgs e)
        {
            Close();
        }

        private void frmMostrarHistoricoIngresoPedido_Load(object sender, EventArgs e)
        {
            historico_IngPedidoBindingSource.DataSource = historicopedidoBL.GetAllFromHistoricoDetallePedido();
            rdbFechas.Checked = true;
            txtRaz_Soc.Visible = false;
            lblRaz_Soc.Visible = false;
        }

        private void btnMostrarTodo_Click(object sender, EventArgs e)
        {
            historico_IngPedidoBindingSource.DataSource = historicopedidoBL.GetAllFromHistoricoDetallePedido();
        }

        private void btnBuscarHistoricoAB_Click(object sender, EventArgs e)
        {
            if (rdbFechas.Checked == true)
            {
                historico_IngPedidoBindingSource.DataSource = historicopedidoBL.GetAllFromHistoricoDetallePedidoByFecha((Convert.ToDateTime(dtpDesde.Value.ToString())).AddDays(-1), Convert.ToDateTime(dtpHasta.Value.ToString()));
            }
            else if (rdbRaz_Soc.Checked == true)
            {
                historico_IngPedidoBindingSource.DataSource = historicopedidoBL.GetAllFromHistoricoDetallePedidoByRazSoc(txtRaz_Soc.Text);
            }
        }

        private void rdbRaz_Soc_CheckedChanged(object sender, EventArgs e)
        {
            if (rdbRaz_Soc.Checked == true)
            {
                dtpDesde.Visible = false;
                dtpHasta.Visible = false;
                lblDesde.Visible = false;
                lblHasta.Visible = false;
                lblRaz_Soc.Visible = true;
                txtRaz_Soc.Visible = true;
            }
            else if (rdbFechas.Checked == true)
            {
                dtpDesde.Visible = true;
                dtpHasta.Visible = true;
                lblDesde.Visible = true;
                lblHasta.Visible = true;
                lblRaz_Soc.Visible = false;
                txtRaz_Soc.Visible = false;
            }
        }
    }
}
